1 USE [SV]
2 GO

3 /****** Object: StoredProcedure [dbo].[pr_themsinhvien] Script Date:
05/31/2018 22:07:31 ******/
4 SET ANSI_NULLS ON
5 GO
6 SET QUOTED_IDENTIFIER ON

7 select
* from thongtin
8 truncate table thongtin
9 pr_themsinhvien
12345,N'Phan Ngọc Hùng',45,8.5
10 ALTER proc [dbo].[pr_themsinhvien]
11 (@MSV nvarchar(
5),
12 @HoTen nvarchar(
50),
13 @Lop
char(4),
14 @Diem
float
15 )

16 as
17 if
exists(select * from thongtin where MSV=@MSV and TEN=@HoTen and LOP=@Lop and DIEM=@Diem)
18 select
ErrCode=1,ErrMsg=N'Đã tồn tài dữ liệu này!'
19 else

20 begin
21 insert
into thongtin(MSV,TEN,LOP,DIEM) values(@MSV,@HoTen,@Lop,@Diem)
22 if
(@@ROWCOUNT>0)
23 select
ErrCode=0,ErrMsg=N'Thêm thành công !!'
24 else
25 select
ErrCode=1,ErrMsg=N'Có lỗi xảy ra!'
26 end



Quản lý sinh viên sử dụng vb.net + sql server 22.436 lượt xem

Gõ tìm kiếm nhanh...